﻿<%@page contentType="text/html; charset=utf-8" language="java" import="cn.ac.cintcm.synonymous.*"  errorPage="" %>
<%@page import="java.util.HashMap" %>
<% 
request.setCharacterEncoding("utf8");
String  fileName  = request.getParameter("fileName");
if (fileName == null) {
   response.sendRedirect("upload.html");
}
String id = request.getParameter("id");
String primary = request.getParameter("primary");
String  synonymous  = request.getParameter("synonymous");
String[] display = request.getParameterValues("display");
String displayStr = Util.array2String (display, Config.FIELD_SEPERATOR);
if(display==null){
    displayStr  = request.getParameter("displayStr");
}
String  itemseparator  = request.getParameter("itemseparator");
String  dictionary  = request.getParameter("dictionary");
String  result  = request.getParameter("result"); 
Message msg  = null;
if (itemseparator  != null && !itemseparator.equals("")) {
     HashMap map = new HashMap();
     map.put("datasource", fileName);
     map.put("dictionary", dictionary);
     map.put("result", result);
     map.put("itemseparator", itemseparator);
     map.put("idField", id);
     map.put("primaryField", primary);
     map.put("synonymousField", synonymous);
     map.put("displayFields", displayStr);
     msg = Config.saveConfig(map);
     Config.loadConfig();
}

%>
<html>
  <head>
   	<meta content="text/html; charset=utf-8" http-equiv="content-type">
	<title>
		正异名修正_参数配置
	</title>
  </head>
  <body>
	<center> 
		<%if(msg != null) {
		     out.print(msg.toString());
		  }
		%>
		
		<form method="post">
			<table>
			<tr>
				<td bgcolor="lightblue" align="left"><b>同异名词条分隔符 : </b></td>
				<td bgcolor="silver" ><input type="text" <%=msg==null?"":"readonly"%> name="itemseparator" value="<%=itemseparator==null?"":itemseparator%>"></td>
			</tr>
			<tr>
				<td bgcolor="lightblue" align="left"><b>词典文件 : </b></td>
				<td bgcolor="silver" ><input type="text" <%=msg==null?"":"readonly"%> name="dictionary" value="<%=dictionary==null?"dict.csv":dictionary%>"></td>
			</tr>
			<tr>
				<td bgcolor="lightblue" align="left"><b>结果保存文件 : </b></td>
				<td bgcolor="silver" ><input type="text" <%=msg==null?"":"readonly"%> name="result" value="<%=result==null?"result.txt":result%>"></td>
			</tr>
			<tr>
				<td bgcolor="lightblue" align="left"><b>数据源文件名称 : </b></td>
				<td bgcolor="silver" ><input readonly name="fileName" value="<%=fileName%>"></td>
			</tr>
			<tr>
				<td bgcolor="lightblue" align="left"><b>关键字段: </b></td>
				<td bgcolor="silver" ><input readonly name="id" value="<%=id%>"></td>
			</tr>
			<tr>
				<td bgcolor="lightblue" align="left"><b>主要显示字段: </b></td>
				<td bgcolor="silver" ><input readonly name="primary" value="<%=primary%>"> </td>
			</tr>
			<tr>
				<td bgcolor="lightblue" align="left"><b>同异名字段: </b></td>
				<td bgcolor="silver" ><input readonly name="synonymous" value="<%=synonymous%>"></td>
			</tr>
			<tr>
				<td bgcolor="lightblue" align="left"><b>辅助显示字段 : </b></td>
				<td bgcolor="silver" ><input readonly name="displayStr" value="<%=displayStr%>"></td>
			</tr>
			<%if (msg == null) {%>
			<tr>
				<td colspan="2" bgcolor="silver" align="center"><input type="submit" value="完成配置"/></td>
			</tr>
			<%} else {%>
			   <a href="index.jsp">开始整理数据</a>
			<%}%>
			</table>
		</form>	
		
	</center>
  </body>
</html>